home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / Python-1.4 / Source / Amiga / Python_netlib / herror.c < prev    next >
C/C++ Source or Header  |  1994-09-29  |  2KB  |  64 lines

  1. RCS_ID_C = "$Id: herror.c,v 4.2 1994/09/29 23:09:02 jraja Exp $";
  2. /*
  3.  *      herror.c - print host error message
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. /****** net.lib/herror *******************************************************
  11.  
  12.     NAME
  13.         herror - print name resolver error message to stderr.
  14.  
  15.     SYNOPSIS
  16.         #include <clib/netlib_protos.h>
  17.  
  18.         herror(banner)
  19.         void herror(const char *)
  20.  
  21.     FUNCTION
  22.         The herror() function finds the error message corresponding to the
  23.         current value of host error using the SocketBaseTags() and writes
  24.         it, followed by a newline, to the stderr. If the argument string
  25.         is non-NULL it is used as a prefix to the message string and
  26.         separated from it by a colon and space (`: '). If the argument is
  27.         NULL only the error message string is printed.
  28.  
  29.     NOTES
  30.         The herror() function requires the stdio functions to be linked.
  31.  
  32.     SEE ALSO
  33.         <netinclude:netdb.h>, SocketBaseTagList(), perror()
  34.  
  35. ******************************************************************************
  36. */
  37.  
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <bsdsocket.h>
  41. #include <amitcp/socketbasetags.h>
  42.  
  43. void 
  44. herror(const char *banner)
  45. {
  46.   const char *err;
  47.  
  48.   /*
  49.    * First fetch the h_errno value to (ULONG)err, and then convert it to 
  50.    * error string pointer.
  51.    */
  52.   SocketBaseTags(SBTM_GETREF(SBTC_HERRNO), &err,
  53.          SBTM_GETREF(SBTC_HERRNOSTRPTR), &err,
  54.          TAG_END);
  55.  
  56.   if (banner != NULL) {
  57.     fputs(banner, stderr);
  58.     fputs(": ", stderr);
  59.   }
  60.   fputs(err, stderr);
  61.   fputc('\n', stderr);
  62.   fflush(stderr);
  63. }
  64.